import { PanelItemController } from '@ibiz-template/runtime'
import { IPanelContainer } from '@ibiz/model-core'
import { PanelContainerGroupState } from './i-biz-panel-container-group.state'

/**
 * 面板分组容器控制器
 *
 * @export
 * @class PanelContainerGroupController
 * @extends {PanelItemController}
 */
export class PanelContainerGroupController extends PanelItemController<IPanelContainer> {
  declare state: PanelContainerGroupState

  protected createState(): PanelContainerGroupState {
    return new PanelContainerGroupState(this.parent?.state)
  }

  /**
   * 禁用关闭
   *
   * @author chitanda
   * @date 2022-09-14 14:09:51
   * @readonly
   * @type {boolean}
   */
  get disableClose(): boolean {
    const { titleBarCloseMode: mode } = this.model
    return mode === 0 || mode === undefined
  }

  /**
   * 是否默认展开分组
   *
   * @author chitanda
   * @date 2022-09-14 14:09:09
   * @readonly
   */
  get defaultExpansion(): boolean {
    const { titleBarCloseMode: mode } = this.model
    return this.disableClose || mode === 1
  }
}
